package Singleton;

/**
 * 多线程  安全
 */
public class Singleton_LazyPower {
    private static volatile Singleton_LazyPower instance = null;
    private Singleton_LazyPower() {

    }
    public static Singleton_LazyPower getInstance() {
        //使后续线程不必再进行锁竞争
        if(instance == null) {
            synchronized (Singleton_LazyPower.class) {
                //初始化对象
                if(instance == null) {
                    instance = new Singleton_LazyPower();
                }
            }
        }
        return instance;
    }
}
